package hd.cls5;

import java.util.Objects;

/**
 * @author oldliu
 * @since 1.0
 */
public class Employee implements Comparable<Employee> {
    private String name;
    private int age;
    private String gender;
    private String position;
    private double salary;
    private int id;

    //无参的建议保留，方便以后扩展
    public Employee() {

    }

    public Employee(String name, int age, String gender, String position, double salary, int id) {
        this.name = name;
        this.age = age;
        this.gender = gender;
        this.position = position;
        this.salary = salary;
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public int getAge() {
        return age;
    }

    public String getGender() {
        return gender;
    }

    public String getPosition() {
        return position;
    }

    public double getSalary() {
        return salary;
    }

    public int getId() {
        return id;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Employee employee = (Employee) o;
        return id == employee.id;
    }

    @Override
    public int hashCode() {
        return Objects.hash(id);
    }

    @Override
    public String toString() {
        return "Employee{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", gender='" + gender + '\'' +
                ", position='" + position + '\'' +
                ", salary=" + salary +
                ", id=" + id +
                '}';
    }

    @Override//可比较
    //this 和  o 比较
    //
    public int compareTo(Employee o) {
        //return (int) (this.salary * 100 - o.salary * 100);
        return this.age - o.age;
        //return this.name.compareTo(o.name);
    }
}

